﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;

namespace PowerPivotUpdater
{
    public class SiteSelector : StringConverter
    {


        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }

        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            object o = context.Instance;
            Type T = o.GetType();
            PropertyInfo P = T.GetProperty("BrowsableObject");
            object o2 = P.GetValue(o, new object[] { });

            Type T2 = o2.GetType();
            PropertyInfo P2 = T2.GetProperty("InnerObject");
            object o3 = P2.GetValue(o2, new object[] { });
            UpdatePPTask u = (UpdatePPTask)o3;


            if (u.ExcelFileURL == "")
                return new StandardValuesCollection(new string[] { "Web oor Excel URL not Configured" });

            return new StandardValuesCollection(ExcelServiceManager.GetSiteURL(u.ExcelFileURL));
        }

    }
}
